package com.raos.example.memory.entity;

import com.fasterxml.jackson.annotation.JsonFormat;
import jakarta.persistence.*;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.time.LocalDateTime;

/**
 * 聊天室实体类
 *
 * @author raos
 * @date 2025-07-14 20:48
 */
@NoArgsConstructor
@Data
@Table(name = "ai_chat_room", indexes = {
        @Index(name = "roomId_chatroom_index", columnList = "roomId")
})
@Entity(name = "AI会话-聊天室")
public class ChatRoom {

    /**
     * 数据库主键（聊天室ID）
     */
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    private Long id;

    @Column(columnDefinition = "varchar(36) NOT NULL COMMENT '聊天室ID'")
    private String roomId;

    /**
     * 聊天室名称
     */
    @Column(columnDefinition = "varchar(256) DEFAULT NULL COMMENT '聊天室名称'")
    private String roomName;

    /**
     * 添加时间
     */
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    @Column(columnDefinition = "datetime DEFAULT NULL COMMENT '添加时间'")
    private LocalDateTime addTime;

    /**
     * 最后更新时间
     */
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    @Column(columnDefinition = "datetime DEFAULT NULL COMMENT '最后更新时间'")
    private LocalDateTime updateTime;

    /**
     * 版本号（默认值为0）
     */
    @Version
    @Column(columnDefinition = "int(11) DEFAULT 0 COMMENT '版本号'")
    private Integer version;

    public ChatRoom(String roomId) {
        this.roomId = roomId;
    }

}
